package com.fhz.day007.delagate

import kotlin.reflect.KProperty

/**
 * 时间:2021/10/21
 * @author msfeng
 * 简述: TODO
 */
class MyClass {
    var p by Delagate()
}

fun main(){
    val myClass = MyClass()
    myClass.p = 123
    val p = myClass.p
    println(p)
}

class Delagate{
    var propValue: Any? = null
    operator fun getValue(clazz: Any, property: KProperty<*>) =  propValue

    operator fun setValue(myClass: Any, property: KProperty<*>, any: Any?) {
        propValue = any
    }

}